package com.tdam2012.grupo04;

import android.os.Bundle;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TabHost;
import android.widget.TextView;

public class ContactScreenActivity extends TabActivity implements OnClickListener{
	public static final String KEY_CONTACT = "Contact";
	
	
	private TextView txtContactName;
	private Contact contact = new Contact();
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.activity_contact_screen);
        txtContactName = (TextView) findViewById(R.id.txtContactNameScreen);
        loadData();
        
        Resources res = getResources();
        
        
		TabHost tabs = (TabHost) findViewById(android.R.id.tabhost);
        tabs.setup();
        
        
        TabHost.TabSpec spec=tabs.newTabSpec("tabHistorialContacto");
        Intent actividad = new Intent(this,ActionsActivity.class);
        actividad.putExtra(KEY_CONTACT,contact);
        spec.setContent(actividad);
        spec.setIndicator(getString(R.string.ContactScreenActivity_historial),res.getDrawable(android.R.drawable.ic_menu_recent_history));
        tabs.addTab(spec);
        
        spec=tabs.newTabSpec("tabLlamar");
		Intent illamar = new Intent(this,CallListActivity.class);
	    illamar.putExtra(KEY_CONTACT,contact);
        spec.setContent(illamar);
        spec.setIndicator(getString(R.string.ContactScreenActivity_llamar),res.getDrawable(android.R.drawable.ic_menu_call));
        tabs.addTab(spec);
        
        spec=tabs.newTabSpec("tabMensajeViaWeb");
        Intent iweb = new Intent(this,LoginActivity.class);
	    iweb.putExtra(KEY_CONTACT,contact);
        spec.setContent(iweb);
        spec.setIndicator(getString(R.string.ContactScreenActivity_mensajeWeb),res.getDrawable(android.R.drawable.ic_menu_share));
        tabs.addTab(spec);
         
        spec=tabs.newTabSpec("tabEmail");
        Intent iemail = new Intent(this,EmailListActivity.class);
	    iemail.putExtra(KEY_CONTACT,contact);
        spec.setContent(iemail);
        spec.setIndicator(getString(R.string.ContactScreenActivity_email),res.getDrawable(android.R.drawable.ic_menu_send));
        tabs.addTab(spec);
        
        spec=tabs.newTabSpec("tabMensajeDeTexto");
        Intent iSMS = new Intent(this,MessageListActivity.class);
	    iSMS.putExtra(KEY_CONTACT,contact);
        spec.setContent(iSMS);
        spec.setIndicator(getString(R.string.ContactScreenActivity_sms),res.getDrawable(android.R.drawable.ic_dialog_email));
        tabs.addTab(spec);
        
        tabs.setCurrentTab(2);
    }
    
    public void loadData(){
        contact = (Contact) getIntent().getSerializableExtra(ContactsActivity.KEY_CONTACT);
    	if(contact == null){
    		return;
    	}
	}
    
    public void showContact(Contact c){
    	txtContactName.setText(c.get_nombre());
    }
    

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
       return true;
    }
    
    protected void onResume(){
    	super.onResume();
    	showContact(contact);
    }
    
    
    
	@Override
	public void onClick(View v) {
		
	}
	
}

